import {SchemaComponents} from "@formily/react"
import {
    Input,
    TimePicker,
    Transfer,
    Switch,
    ArrayCards,
    ArrayTable,
    ArrayTabs,
    ArrayCollapse,
    ArrayItems,
    PreviewText,
    Space,
    Checkbox,
    DatePicker,
    NumberPicker,
    Password,
    Radio,
    Upload,
    Select,
    TreeSelect,
    Editable,
    Cascader,
    FormCollapse,
    FormLayout,
    FormStep,
    FormTab,
    FormGrid,
    FormItem,
    Submit,
    Reset,
} from '@formily/antd-v5'


const innerComponents: SchemaComponents = {
    Input,
    TextArea: Input.TextArea,
    TimePicker,
    Transfer,
    Switch,
    ArrayCards,
    "ArrayCards.Index": "ArrayCards.Index",
    "ArrayCards.Addition": "ArrayCards.Addition",
    "ArrayCards.Remove": "ArrayCards.Remove",
    "ArrayCards.MoveUp": "ArrayCards.MoveUp",
    "ArrayCards.MoveDown": "ArrayCards.MoveDown",
    ArrayTable,
    ArrayTabs,
    ArrayCollapse,
    ArrayItems,
    PreviewText,
    Space,
    Checkbox,
    CheckboxGroup: Checkbox.Group,
    DatePicker,
    RangePicker: DatePicker.RangePicker,
    NumberPicker,
    Password,
    Radio,
    RadioGroup: Radio.Group,
    Range,
    TreeSelect,
    Upload,
    Select,
    Editable,
    Cascader,
    FormCollapse,
    "FormCollapse.CollapsePanel": FormCollapse.CollapsePanel,
    FormLayout,
    FormStep,
    FormTab,
    "FormTab.TabPane": FormTab.TabPane,
    FormGrid,
    FormItem,
    Submit,
    Reset,
};

// 获取内置组件
export const getInnerComponents = (): SchemaComponents => {
    const components = {};
    Object.keys(innerComponents).forEach((componentName) => {
        // @ts-ignore
        components[componentName] = innerComponents[componentName];
        // @ts-ignore
        components[componentName.replace(componentName[0], componentName[0].toLowerCase())] = innerComponents[componentName];
    });

    return components;
}